package com.efast.dmom.mes.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.efast.dmom.mes.bean.QualityProductDefect;
import com.efast.dmom.mes.bean.ResultBean;
import com.efast.dmom.mes.entity.base.IModificationFlags;
import com.efast.dmom.mes.service.QualityProductDefectService;

@Controller
@RequestMapping("/qualityProductDefect")
public class QualityProductDefectController {
	@Autowired
	private QualityProductDefectService qualityProductDefectService;
	
	@RequestMapping(value = "/addOrEdit")
	public @ResponseBody ResultBean addOrEdit(@RequestBody QualityProductDefect qualityProductDefect) {
		if (qualityProductDefect.getModificationFlag() == IModificationFlags.NEW) {
			ResultBean save = qualityProductDefectService.save(qualityProductDefect);
			return save;
		} else if (qualityProductDefect.getModificationFlag() == IModificationFlags.MODIFIED) {
			ResultBean update = qualityProductDefectService.update(qualityProductDefect);
			return update;
		}
		return null;
	}
	
	@RequestMapping(value = "/batchDelete")
	public @ResponseBody ResultBean batchDelete(@RequestBody List<QualityProductDefect> list) {
		ResultBean batchDelete = qualityProductDefectService.batchDelete(list);
		return batchDelete;
	}
	

}
